package work8;

import java.util.Scanner;

public class Quetion2 {
    public static void main(String[] args) {
        // Scanner input = new Scanner(System.in, "GBK");
        Scanner input = new Scanner(System.in);

        while (true) {
            System.out.println("请输入空格分隔的长方体颜色、填充（true/false）、底面长、宽和高");
            System.out.print("(end结束程序):");
            String color = input.next();
            if (color.equals("end")) {
                break;
            }
            boolean isFilled = input.nextBoolean();
            double length = input.nextDouble();
            double width = input.nextDouble();
            double high = input.nextDouble();
            Rectlinder rectlinder = new Rectlinder(color, isFilled, length, width, high);
            System.out.printf("所构建图形信息：\n%s\n", rectlinder.toString());
        }
        System.out.println("程序结束");
        input.close();
    }
}

class Geom {
    private String color;
    private boolean isFilled;

    public Geom() {

    }

    public Geom(String color, boolean isFilled) {
        this.color = color;
        this.isFilled = isFilled;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public boolean isFilled() {
        return this.isFilled;
    }

    public void setFilled(boolean isFilled) {
        this.isFilled = isFilled;
    }

    public String toString() {
        return String.format("      颜色：%s\n      是否有填充：%b", this.color, this.isFilled);
    }
}

class Rectangle extends Geom {
    private double length;
    private double width;

    public Rectangle() {
        super();
    }

    public Rectangle(String color, boolean isFilled, double length, double width) {
        super.setColor(color);
        super.setFilled(isFilled);
        this.length = length;
        this.width = width;
    }

    public double getLength() {
        return this.length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return this.width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getArea() {
        return this.length * this.width;
    }
}

class Rectlinder extends Rectangle {
    private double high;

    public Rectlinder() {
    }

    public Rectlinder(String color, boolean isFilled, double length, double width, double high) {
        super.setColor(color);
        super.setFilled(isFilled);
        super.setLength(length);
        super.setWidth(width);
        this.high = high;
    }

    public double getHigh() {
        return high;
    }

    public double getVolume() {
        return super.getArea() * this.high;
    }

    public String toString() {
        return String.format("%s\n      体积为：%.1f", super.toString(), this.getVolume());
    }

}